package it.text;

import java.util.Scanner;

public class text05 {
    public static void main(String[] args) {
        double avg=avgeSix();
        System.out.println("平均分为:"+avg);
    }

    private static double avgeSix() {
        int[] score = getData();
        double avge = getAvge(score);
        return avge;
    }

    private static double getAvge(int[] score) {
        int max= score[0],min= score[0],sum=0;
        double avge=0;
        for (int n = 0; n < score.length; n++) {
            if (score[n] < max) {
                max= score[n];
            }
            else if (score[n] > min) {
                min= score[n];
            }
            sum+= score[n];
        }
        avge=((sum-min-max)*1.0)/ (score.length-2);
        return avge;
    }

    private static int[] getData() {
        Scanner sc = new Scanner(System.in);
        int[] score=new int[6];
        int att=0;
        for (int i = 0; i < score.length; i++) {
            System.out.println("第"+(i+1)+"位评委打分:");
            att=sc.nextInt();
            if(att<0||att>100){
                System.out.println("成绩输入有误，不在0-100范围内，请检查！");
                i--;
            }
            else  {
                score[i]=att;
            }
        }
        return score;
    }


}
